/**
 * ATuanZhang
 */
package org.huanglei.android.inject.module;

import org.huanglei.android.inject.provider.ActivityProvider;
import org.huanglei.android.inject.provider.SystemServiceProvider;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.KeyguardManager;
import android.app.NotificationManager;
import android.app.SearchManager;
import android.content.Context;
import android.hardware.SensorManager;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
import android.os.PowerManager;
import android.os.Vibrator;
import android.telephony.TelephonyManager;
import android.view.LayoutInflater;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;

import com.google.inject.Provider;

/**
 * @author huanglei
 * @date 2011-3-25 @
 */
public class AndroidModule extends AbstractAndroidModule {

	protected Provider<Context> contextProvider = null;

	public AndroidModule(Provider<Context> contextProvider) {
		this.contextProvider = contextProvider;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.google.inject.AbstractModule#configure()
	 */
	@Override
	protected void configure() {

		bind(Activity.class).toProvider(ActivityProvider.class);

		/**
		 * Context
		 */
		bind(Context.class).toProvider(contextProvider);

		// Inject System Services
		/**
		 * Location 位置的服务，如GPS
		 */
		bind(LocationManager.class).toProvider(
				new SystemServiceProvider<LocationManager>(
						Context.LOCATION_SERVICE));

		/**
		 * Window 管理打开的窗口程序
		 */
		bind(WindowManager.class)
				.toProvider(
						new SystemServiceProvider<WindowManager>(
								Context.WINDOW_SERVICE));

		/**
		 * LayoutInflater 取得xml里定义的view
		 */
		bind(LayoutInflater.class).toProvider(
				new SystemServiceProvider<LayoutInflater>(
						Context.LAYOUT_INFLATER_SERVICE));

		/**
		 * Activity 管理应用程序的系统状态
		 */
		bind(ActivityManager.class).toProvider(
				new SystemServiceProvider<ActivityManager>(
						Context.ACTIVITY_SERVICE));

		/**
		 * Power 电源的服务
		 */
		bind(PowerManager.class).toProvider(
				new SystemServiceProvider<PowerManager>(Context.POWER_SERVICE));

		/**
		 * Alarm 闹钟的服务
		 */
		bind(AlarmManager.class).toProvider(
				new SystemServiceProvider<AlarmManager>(Context.ALARM_SERVICE));

		/**
		 * Notification 状态栏的服务
		 */
		bind(NotificationManager.class).toProvider(
				new SystemServiceProvider<NotificationManager>(
						Context.NOTIFICATION_SERVICE));

		/**
		 * Keyguard 键盘锁的服务
		 */
		bind(KeyguardManager.class).toProvider(
				new SystemServiceProvider<KeyguardManager>(
						Context.KEYGUARD_SERVICE));

		/**
		 * Search 搜索的服务
		 */
		bind(SearchManager.class)
				.toProvider(
						new SystemServiceProvider<SearchManager>(
								Context.SEARCH_SERVICE));

		/**
		 * Vibrator 手机震动的服务
		 */
		bind(Vibrator.class).toProvider(
				new SystemServiceProvider<Vibrator>(Context.VIBRATOR_SERVICE));

		/**
		 * Connectivity 网络连接的服务
		 */
		bind(ConnectivityManager.class).toProvider(
				new SystemServiceProvider<ConnectivityManager>(
						Context.CONNECTIVITY_SERVICE));

		/**
		 * Wifi Wi-Fi服务
		 */
		bind(WifiManager.class).toProvider(
				new SystemServiceProvider<WifiManager>(Context.WIFI_SERVICE));

		/**
		 * InputMethod 软键盘
		 */
		bind(InputMethodManager.class).toProvider(
				new SystemServiceProvider<InputMethodManager>(
						Context.INPUT_METHOD_SERVICE));

		/**
		 * Sensor 重力感应
		 */
		bind(SensorManager.class)
				.toProvider(
						new SystemServiceProvider<SensorManager>(
								Context.SENSOR_SERVICE));

		/**
		 * Telephony 电话服务
		 */
		bind(TelephonyManager.class).toProvider(
				new SystemServiceProvider<TelephonyManager>(
						Context.TELEPHONY_SERVICE));

		/**
		 * 自定义inject
		 * 
		 * bindListener(Matchers.any(), new ViewListener(contextProvider));
		 * bindListener(Matchers.any(), new ResourceListener(contextProvider));
		 * 
	
		 */

	}

}
